<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

		<title>个人中心</title>

		<link href="../AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css">
		<link href="../AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css">
		<link href="../css/personal.css" rel="stylesheet" type="text/css">
		<link href="../css/vipstyle.css" rel="stylesheet" type="text/css">
		<script src="../AmazeUI-2.4.2/assets/js/jquery.min.js"></script>
		<script src="../AmazeUI-2.4.2/assets/js/amazeui.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>
	</head>

	<body>
		<!--头 -->
		<header>
			<article>
				<div class="mt-logo">
					<!--顶部导航条 -->
					<div class="am-container header">
						<ul class="message-l">
							<div class="topMessage">
								<div class="menu-hd" id="indexHeader">
								</div>
							</div>
						</ul>
						<ul class="message-r">
							<div class="topMessage home">
								<div class="menu-hd">
									<a href="index.html" target="_top" class="h">商城首页</a>
								</div>
							</div>
						</ul>
					</div>
					<div class="nav white">
					</div>

					<div class="clear"></div>
				</div>
				</div>
			</article>
		</header>
		<div class="nav-table">
			<h1 style="font-size: 30px;color: #FB0000;font-family: KaiTi">花鸟鱼虫特卖网</h1>
		</div>
		<div class="center">
			<div class="col-main">
				<div class="main-wrap">
					<div class="wrap-left">
						<div class="wrap-list">
							<div class="m-user">
								<!--个人信息 -->

								<div class="m-userinfo">
									<a href="news.html">
										<div class="tipsBox"><i class="am-icon-envelope"></i></div>
									</a>
									<div class="m-baseinfo">
										<a class="m-pic" href="information.html">
											<img id="headImg" src="../images/no-img_mid_.jpg">
										</a>
										<div class="m-info">
											<em class="s-name" id="userNick"></em>
										</div>
									</div>
								</div>

								<!--我的钱包-->
								<div class="wallet">
									<div class="s-bar">
										<i class="s-icon"></i>个人资产
									</div>
									<p class="m-big squareL">
										<a href="#">
											<i><img src="../images/profit.png"/></i>
											<span class="m-title" id="money"></span>
										</a>
									</p>
									<p class="m-big squareS">
										<a href="#">
											<i><img src="../images/coupon.png"/></i>
											<span class="m-title" id="coupon">优惠券</span>
										</a>
									</p>
								</div>
							</div>
						</div>
					</div>
					<div class="clear"></div>
				</div>
			</div>

			<!--侧边栏-->
			<aside class="menu">
				<ul>
					<li class="person active">
						<a href="pindex.html" style="color: #222">个人中心</a>
					</li>
					<li class="person">
						<p><a href="pinformation.html">个人信息</a></p>
					</li>
					<li class="person">
						<p><a href="order.html">订单管理</a></p>
					</li>
				</ul>
			</aside>
			
		</div>
		
		<script>
			$(function(){
				/*检验用户是否登录*/
				if (getCookie("username") == null || getCookie("userid") == null) {
                    window.location.href="login.html";
                    return;
			    }else{
			    	$("#indexHeader").append(`
                            <a href="#" target="_top" class="h">您好，${getCookie("username")}</a>
                            <a href="javascript:void(0);" onclick="clearCookie()">退出</a>`
                    );
			    }
			    
			   /*根据userid请求数据*/
			   var userid=getCookie("userid");
			   //个人信息
			   $.ajax({
			   		type:"get",
					url:"/user/info/"+userid,
					success:function(result){
						var money=result.data.money;
						$("#money").text(money+"元");
						$("#userNick").text(result.data.username);
						$("#headImg").attr("src",result.data.headimg);
					}
			   });
			   //查询优惠券
			   $.get("/user/selectCoupons/"+userid+"/-1",function(res){
				   $("#coupon").text(res.length+"张优惠券");
			   })
			})	
		</script>
	</body>

</html>